import request from '@/utils/request'

/**
 * 会员列表
 * @returns {*}
 */
export function getMemberList(params) {
  return request({
    url: '/systemj/member/list',
    method: 'get',
    params: params
  })
}

/**
 * 编辑会员
 * @param data
 * @returns {*}
 */
export function modifyMember(data) {
  return request({
    url: `/systemj/member${data.id ? '' : '/backAdd'}`,
    method: data.id ? 'put' : 'post',
    data: data
  })
}

/**
 * 停用/启用会员
 * @param member
 * @returns {*}
 */
export function changeMemberStatus(member) {
  return request({
    url: `/systemj/member/enable/${member.id}/${member.status == 0}`,
    method: 'post'
  })
}

/**
 * 会员续费
 * @param data
 * @returns {*}
 */
export function memberRenew(data) {
  return request({
    url: '/systemj/member/backRenwal',
    method: 'post',
    data: data
  })
}


/**
 * 会员卡列表
 * @returns {*}
 */
export function getCardList(params) {
  return request({
    url: '/systemj/memberConfig/list',
    method: 'get',
    params: params
  })
}

export function relateProject(params) {
  return request({
    url: '/systemj/projectConfig/listCanUse',
    method: 'get',
    params: params
  })
}

/**
 * 编辑会员卡
 * @param data
 * @returns {*}
 */
export function modifyCard(data) {
  return request({
    url: '/systemj/memberConfig',
    method: data.id ? 'put' : 'post',
    data: data
  })
}

/**
 * 生成会员卡号
 * @param id
 * @returns {*}
 */
export function getCardNum(id) {
  return request({
    url: `/systemj/member/generateCardCode/${id}`,
    method: 'post'
  })
}



/**
 * 修改会员卡状态
 * @param venue
 * @returns {*}
 */
export function changeCardStatus(card) {
  return request({
    url: `/systemj/memberConfig/enable/${card.id}/${card.status == 0}`,
    method: 'post'
  })
}

/**
 * 修改折扣
 * @param data
 * @returns {*}
 */
export function editDiscount(data) {
  return request({
    url: `/systemj/member/editDiscount`,
    method: 'post',
    data: data
  })
}

/**
 * 充值
 * @param data
 * @returns {*}
 */
export function backOnlyRecharge(data) {
  return request({
    url: `/systemj/member/backOnlyRecharge`,
    method: 'post',
    data: data
  })
}

/**
 * 删除会员卡
 * @param id
 * @returns {*}
 */
export function delCard(id) {
  return request({
    url: `/systemj/memberConfig/${id}`,
    method: 'delete'
  })
}

/**
 * 统计人员信息
 * @returns {*}
 */
export function getMemberStatisticsInfo() {
  return request({
    url: '/systemj/member/getMemberStatisticsInfo',
    method: 'get'
  })
}
export function rechargeList(params) {
  return request({
    url: '/systemj/memberOrder/list/recharge',
    method: 'get',
	params: params
  })
}
export function listConsume(params) {
  return request({
    // url: '/systemj/memberBalanceFlow/listConsume',
    url: '/systemj/memberBalanceFlow/selectPageList',
    method: 'get',
	params: params
  })
}

// 退卡列表
export function confirmList(params) {
  return request({
    url: '/systemj/memberOrder/getToBeConfirmList',
    method: 'get',
	params: params
  })
}
// 退卡确认
// /systemj/member/refundConfirm 退卡确认 url上带上memberOrderId
export function refundConfirm(memberOrderId) {
  return request({
    url: `/systemj/member/refundConfirm/${memberOrderId}`,
    method: 'post'
  })
}


export function importUser(data) {
  return request({
    url: `/systemj/member/importUser`,
    method: 'post',
	data: data
  })
}

// 会员退卡
export function refundCard(data) {
  return request({
    url: '/systemj/member/refundCard',
    method: 'post',
    data: data
  })
}

